@extends('web.index')
@section('con')
    @include('common.message')
    <ol class="breadcrumb">
        <li class="active">测试</li>
        <li class="active">政治</li>
        <li class="active">选择题</li>
    </ol>
    @if(session('polity_choice'))
        <p style="display: none;" id="recovery" class="alert alert-danger">未完成试题已恢复</p>
        <script>
            $('#recovery').slideDown();
            setTimeout(function () {
                $('#recovery').slideUp();
            }, 3000)
        </script>
    @endif
    {{ session(['polity_choice' => $data->pluck('id')]) }}
    <form action="{{url('polity/result')}}" method="post">
        @foreach($data as $k=>$v)
            <div class="alert alert-success alert-dismissible animated @if(++$k%2==0) bounceInLeft @else bounceInRight @endif"
                 role="alert" style="text-align: left;padding: 15px;">
                <h4>{{$k}}. {{ $v->title }}</h4>
                <div class="radio" style=" text-indent:1em">
                    <label class="radio">
                        <input type="radio" name="answer[{{ $v->id }}]" value="A"
                               @if(old('answer.'.$v->id)=='A') checked @endif><b>A.</b> {{ $v->option_a }}
                    </label>
                </div>
                <div class="radio" style=" text-indent:1em">
                    <label class="radio">
                        <input type="radio" name="answer[{{ $v->id }}]" value="B"
                               @if(old('answer.'.$v->id)=='B') checked @endif><b>B.</b> {{ $v->option_b }}
                    </label>
                </div>
                <div class="radio" style=" text-indent:1em">
                    <label class="radio">
                        <input type="radio" name="answer[{{ $v->id }}]" value="C"
                               @if(old('answer.'.$v->id)=='C') checked @endif><b>C.</b> {{ $v->option_c }}
                    </label>
                </div>
                <div class="radio" style=" text-indent:1em">
                    <label class="radio">
                        <input type="radio" name="answer[{{ $v->id }}]" value="D"
                               @if(old('answer.'.$v->id)=='D') checked @endif><b>D.</b> {{ $v->option_d }}
                    </label>
                </div>
                <input type="hidden" name="right[{{ $v->id }}]" value="{{ $v->answer }}">
                <button type="button" onclick="see({{$v->id}})" class="btn btn-danger">查看答案</button>
                <em id="{{$v->id}}" style="display:none;">正确答案：<b>{{ $v->answer }}</b></em>
            </div>
        @endforeach
        @csrf
        <button id="jiaojuan" class="btn btn-primary">交卷</button>
    </form>
    <script>
        function see(id) {
            $('#' + id).show();
        }

        $('#jiaojuan').click(function () {
            $(this).html('<i class="fa fa-spinner fa-pulse"></i>').css('width', '54px');
        });
    </script>
@endsection